<!--
 * @Descripttion: 
 * @version: 1.0.0
 * @Author: Wupy
 * @Date: 2023-01-05 17:49:29
 * @LastEditors: Wupy
 * @LastEditTime: 2023-02-21 11:25:59
-->
<template>
    <div class="chapterCard" v-for="item in lessonInfo">
        <div class="chapterItem">
        <!-- <div class="chapterItemId">
                {{ item.chapterItemGroupId }}
                </div> -->
            <div class="chapterItemName">
                {{ item.name }}
            </div>
            <div v-for="i in item.sectionList" class="classItem">
                <!-- <div class="itemId">
                        {{ i.courseId }}
                    </div> -->
                <div class="itemName" @click="toLessonDetail(i.id)">
                    {{ i.name }}
                </div>
            </div>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router';
import { useLessonStore } from '@/stores/lesson'
import { storeToRefs } from 'pinia'
const route = useRoute()
const router = useRouter()
const lessonStore = useLessonStore()

const { LessonInFo } = lessonStore
const { lessonInfo } = storeToRefs(lessonStore)

const courseId = route.query.courseId || localStorage.getItem('courseId')

const chapterList = ref([
    {
        chapterItemGroupId: '1',
        chapterItemGroupName: '第一章',
        chapterItemGroup: [
            {
                chapterItemId: '1.1',
                chapterItemName: '马克思主义在农大',
            }, {
                chapterItemId: '1.1',
                chapterItemName: '马克思主义在农大',
            }, {
                chapterItemId: '1.1',
                chapterItemName: '马克思主义在农大',
            },
        ]
    },
    {
        chapterItemGroupId: '1',
        chapterItemGroupName: '第二章',
        chapterItemGroup: [
            {
                chapterItemId: '1.1',
                chapterItemName: '马克思主义在农大',
            }, {
                chapterItemId: '1.1',
                chapterItemName: '马克思主义在农大',
            }, {
                chapterItemId: '1.1',
                chapterItemName: '马克思主义在农大',
            },
        ]
    },
    {
        chapterItemGroupId: '1',
        chapterItemGroupName: '第三章',
        chapterItemGroup: [
            {
                chapterItemId: '1.1',
                chapterItemName: '马克思主义在农大',
            }, {
                chapterItemId: '1.1',
                chapterItemName: '马克思主义在农大',
            }, {
                chapterItemId: '1.1',
                chapterItemName: '马克思主义在农大',
            },
        ]
    },

])
onMounted(async () => {
    await LessonInFo(courseId)
})
// 点击章节的方法
const toLessonDetail = (id: string) => {
    console.log(id);
    router.push({ path: '/classDetail', query: { id } })
}


</script>

<style lang="less" scoped>
.chapterCard {
    width: 390px;
}

.chapterItem {

    // padding-left: 15px;
    // padding-top: 5px;
    line-height: 30px;

    .chapterItemId {
        color: #A0A4BF;
    }

    .chapterItemName {
        color: black;
        font-size: 18px;
        font-weight: 300;
        padding-left: 8px;
        font-size: 16px;
        display: block;
        background-color: rgb(219, 219, 223);
        border-radius: 15px;
    }

    .classItem {
        display: flex;

        .itemId {
            color: #A0A4BF;
            padding-left: 5px;
            padding-right: 10px;
        }

        .itemName {
            color: black;
            font-weight: 400;
            padding-left: 15px;

        }
    }
}</style>